%ifndef BOOT_PROTECTEDMODEUTILITY_VIDEOTEXTMODELOCATECURSOR
%define BOOT_PROTECTEDMODEUTILITY_VIDEOTEXTMODELOCATECURSOR
; DWORD VideoTextModeLocateCursor()
; 返回值保存在 eax 寄存器中
bits 32
VideoTextModeLocateCursor:
    push edx
    xor eax, eax
    mov dx, 0x03d4 ; CRT Controller Address Register
    mov al, 0x0e ; Cursor Location High Register
    out dx, al ; Enable CRT Controller Address Register -> Cursor Location High Register
    mov dx, 0x03d5 ; CRT Controller Data Registers
    in al, dx ; Read High Cursor Location
    mov ah, al

    mov dx, 0x03d4 ; CRT Controller Address Register
    mov al, 0x0f ; Cursor Location Low Register
    out dx, al ; Enable CRT Controller Address Register -> Cursor Location Low Register
    mov dx, 0x03d5 ; CRT Controller Data Registers
    in al, dx ; Read Low Cursor Location
    pop edx
    ret
%endif